package com.aptemo.webetek.client.widgets;

import com.aptemo.webetek.client.widgets.paging.PagingControl;
import com.aptemo.webetek.client.widgets.paging.SelectionControl;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class BaseListWidget
		extends Composite implements PagingControl, SelectionControl
{

	protected FlexTable		headerlayout	= new FlexTable();
	protected FlexTable		mlayout			= new FlexTable();
	protected VerticalPanel	mpanel			= new VerticalPanel();

	public BaseListWidget()
	{
		super();

		// VerticalPanel headpanel = new VerticalPanel();
		// mlayout.setWidget(0, 0, headpanel);
		mlayout.setWidget(1, 0, mpanel);

		headerlayout.setStyleName("listHeader");
		headerlayout.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
		headerlayout.setVisible(false);
		mlayout.setWidget(0, 0, headerlayout);

		initWidget(mlayout);

	}

	@Override
	public void addPagingControls(Widget w)
	{
		headerlayout.setVisible(true);

		if (null == w)
		{
			headerlayout.setWidget(0, 1, new HTML(""));
			return;
		}
		headerlayout.setWidget(0, 1, w);
	}

	@Override
	public void addSelectionControls(Widget w)
	{
		headerlayout.setVisible(true);
		headerlayout.setWidget(1, 0, w);
	}

}
